package com.drcoffee.drcoffeemall.controller;

import com.drcoffee.drcoffeemall.entry.InvoiceRecords;
import com.drcoffee.drcoffeemall.entry.Result;
import com.drcoffee.drcoffeemall.service.InvoiceService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/invoice")
public class InvoiceController {

    final
    InvoiceService invoiceService;

    public InvoiceController(InvoiceService invoiceService) {
        this.invoiceService = invoiceService;
    }


    /*
     * 获取待开票记录
     * */
    @PostMapping("/getInvoiceData")
    public ResponseEntity<Object> getInvoiceData(@RequestBody Map<String,Object> paramMap) {
        return invoiceService.getInvoiceData(paramMap);
    }


    /*
     * 上传发票
     * */
    @PostMapping("/uploadInvoice")
    public Result uploadInvoice(@RequestParam("file") MultipartFile file, @RequestParam String code,@RequestParam String order_code) {
        return invoiceService.uploadInvoice(file, code,order_code);
    }

    @GetMapping("/updateCurrentStep")
    public HashMap<Object,Integer> updateCurrentStep(@RequestParam("orderCode") String orderCode){
        return  invoiceService.updateCurrentStep(orderCode);
    }
}
